package com.cow.support.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cow.framework.core.base.BaseComponent;
import com.cow.support.dao.RoleDAO;
import com.cow.support.dao.RoleResourceDAO;
import com.cow.support.dao.UserDAO;
import com.cow.support.entity.Roleinfo;
import com.cow.support.entity.Roleresource;
@Service
public class RoleService extends BaseComponent {
	@Autowired
	private RoleDAO roleDAO;
	@Autowired
	private RoleResourceDAO roleResourceDAO;
	@Autowired
	private UserDAO userDAO;

	public List<Roleinfo> getUserRole(Integer userID) {
		return roleDAO.getUserRole(userID);
	}

	public List<Roleinfo> getAllRole(){
		return roleDAO.findAll();
	}

	public Roleinfo getRoleByID(long roleid) {
		return (Roleinfo)roleDAO.findOne(roleid);		
	}


	public void updateRole(Roleinfo roleinfo) {
		roleDAO.save(roleinfo);		
	}	

	public void saveRoleresource(Roleresource roleresource) {
		roleResourceDAO.save(roleresource);
		
	}

	public void saveRoleresource(ArrayList<Roleresource> rList) {
		roleResourceDAO.save(rList);
		
	}

}
